$(function(){
	$("#loginErro").text("");
	$("#pwdErro").text("");
	$("#login").keyup(function(){
		$("#loginErro").text("");
	});
	$("#password").keyup(function(){
		$("#pwdErro").text("");
	});
	$("#login").focus(function(){
		if($("#login").val()=="用户名"){
			$("#login").val("");
		}
		$("#login").css("color","#000000");
	});
	
	$("#password").focus(function(){
		if($("#password").val()=="密 码"){
			$("#password").val("");
			
		}
		$("#password").css("color","#000000");
	});
})
//登录
function login() {
	var flag = true;
	if (flag) {
		flag = false;
		if ($("#login").val() == "" || $("#login").val() == "用户名") {
			showTipMsg("请输入用户名或邮箱地址！",1);
			$("#login").focus();
			return;
		}
		if ($("#password").val() == "") {
			showTipMsg("请输入密码！",2);
			$("#password").focus();
			return;
		}
		var param = {};
//		param["paramMap.pageId"] = "userlogin";//验证码用
		param["paramMap.email"] = $("#login").val();
		param["paramMap.password"] = $("#password").val();
		$.post("wchatLogin.do", param,function(data) {
			if (data == 1) {
				var afterLoginUrl=$("#afterLoginUrl").val();
      	        if(afterLoginUrl != ''){
				   window.location.href=afterLoginUrl;
      	        }else{
      	           window.location.href = "wchatAccount.do";
      	        }
			}  else if (data == 3) {
				//switchCode();
				flag = true;
				showTipMsg("用户名或密码错误！",1);
			} else if (data == 4) {
				//switchCode();
				flag = true;
				showTipMsg("该用户已被锁定！",1);
			} else if(data == 5){
				window.location.href = 'wchatPersonInit.do';
			}
		});
	}
}
function showTipMsg(msg,num){
	if(msg!=""&&num==1){
		$("#loginErro").text(msg);
		$("#pwdErro").text("");
	}else if(msg!=""&&num==2){
		$("#pwdErro").text(msg);
		$("#loginErro").text("");
	}
}
